using System;
using Webshop20.Domain.Catalog.Core.Products;
using Webshop20.Domain.Shared.Products.Core;

namespace Webshop20.UnitTests.Builder
{
    public class BuildProduct
    {
        private decimal price = 14.99m;
        private string name = "My Product";
        private string description = "Best product of the world. Buy it now!!!!";
        private string image = "productImage.jpg";
        private string purchaseOrderNumber = "1234567889";
        private bool isOutdated;
        private Category category = new Category(null, null, "Best products", "All the best", null);
        private Producer producer = new Producer() {ID = 123};
        private int id = 334;
        Discount discount = new Discount(10, DateTime.Now, DateTime.Now.AddDays(14));

        public BuildProduct WithProducer(Producer producer)
        {
            this.producer = producer;
            return this;
        }

        public BuildProduct WithName(string name)
        {
            this.name = name;
            return this;
        }

        public BuildProduct WithCategory(Category category)
        {
            this.category = category;
            return this;
        }

        public BuildProduct WithPrice(decimal price)
        {
            this.price = price;
            return this;
        }

        public BuildProduct WithPurchaseOrderNumber(string number)
        {
            purchaseOrderNumber = number;
            return this;
        }

        public BuildProduct WithId(int id)
        {
            this.id = id;
            return this;
        }

        public static implicit operator Product(BuildProduct buildProduct)
        {
            return buildProduct.Build();
        }

        private Product Build()
        {
            return new Product(price, name, description, image, purchaseOrderNumber, isOutdated, category, producer, discount) { Id = id};
        }

        public BuildProduct WithDiscount(Discount discount)
        {
            this.discount = discount;
            return this;
        }
    }
}